<?php
use think\facade\Route;

// 管理员路由
Route::group('admin', function () {
    // 登录
    Route::post('login', 'api.Login/login');
    Route::post('logout', 'api.Login/logout');
    Route::get('info', 'api.Login/getInfo');
    Route::post('update_password', 'api.Login/updatePassword');
    Route::post('update_info', 'api.Login/updateInfo');
    Route::get('log_list', 'api.Login/getLogList');
    Route::post('clear_log', 'api.Login/clearLog');
    Route::get('menu_list', 'api.Login/getMenuList');
    Route::get('auth_list', 'api.Login/getAuthList');
    Route::get('role_list', 'api.Login/getRoleList');
    Route::get('role_info', 'api.Login/getRoleInfo');
    Route::post('add_role', 'api.Login/addRole');
    
    // 管理员管理
    Route::get('admin_list', 'api.Admin/index');
    Route::post('add_admin', 'api.Admin/add');
    Route::post('edit_admin', 'api.Admin/edit');
    Route::post('delete_admin', 'api.Admin/delete');
    
    // 配送员管理
    Route::get('delivery/index', 'api.Delivery/index');
    Route::post('delivery/add', 'api.Delivery/add');
    Route::post('delivery/edit', 'api.Delivery/edit');
    Route::post('delivery/delete', 'api.Delivery/delete');
    
    // 赋码管理
    Route::get('code/index', 'api.Code/index');
    Route::post('code/generate', 'api.Code/generate');
    Route::post('code/delete', 'api.Code/delete');
    Route::post('code/batch-delete', 'api.Code/batchDelete');
    
    // 合伙人管理
    Route::get('partner/index', 'api.Partner/index');
    Route::post('partner/add', 'api.Partner/add');
    Route::post('partner/edit', 'api.Partner/edit');
    Route::post('partner/delete', 'api.Partner/delete');
    Route::post('partner/audit', 'api.Partner/audit');
    
    // 七牛云管理
    Route::get('qiniu/token', 'api.Qiniu/getUploadToken');
    Route::post('qiniu/upload', 'api.Qiniu/upload');
    Route::post('qiniu/delete', 'api.Qiniu/delete');
    Route::get('qiniu/info', 'api.Qiniu/getFileInfo');
    Route::get('qiniu/list', 'api.Qiniu/getFileList');
    Route::get('qiniu/url', 'api.Qiniu/getFileUrl');
    Route::get('qiniu/download', 'api.Qiniu/getDownloadUrl');
});

// API路由
Route::group('api', function () {
    // 微信授权
    Route::get('wechat/auth_url', 'api.Wechat/getAuthUrl');
    Route::get('wechat/callback', 'api.Wechat/callback');
    
    // 用户
    Route::get('user/info', 'api.User/getInfo');
    Route::post('user/update_phone', 'api.User/updatePhone');
    
    // 支付
    Route::post('payment/create', 'api.Payment/create');
    Route::post('payment/notify', 'api.Payment/notify');
    Route::get('payment/query', 'api.Payment/query');
    
    // 配送员
    Route::post('delivery/login', 'api.Delivery/login');
    Route::get('delivery/orders', 'api.Delivery/getOrders');
    Route::post('delivery/accept', 'api.Delivery/acceptOrder');
    Route::post('delivery/complete', 'api.Delivery/completeOrder');
    
    // 微信消息
    Route::get('wechat/receive', 'api.Wechat/receive');
    Route::post('wechat/receive', 'api.Wechat/receive');
    Route::post('wechat/send_template', 'api.Wechat/sendTemplate');
}); 